<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>
        添加权限
    </title>
    <meta content="webkit" name="renderer">
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="telephone=no" name="format-detection">
    <link href="css/main.css" media="all" rel="stylesheet">
</head>

<body>
<div class="x-body">
    <form action="" class="layui-form layui-form-pane" method="post">
        <input name="id" type="hidden" value=""/>
        <div class="layui-form-item">
            <label class="layui-form-label" for="name">
                <span class="x-red">*</span>上级权限
            </label>
            <div class="layui-input-inline">
                <select name="pid">
                    <option value="0">顶级权限</option>
                    <option value="1">系统设置</option>
                    <option value="2">|———基础设置</option>
                    <option value="3">|——————基础设置操作</option>
                    <option value="9">|———友情链接</option>
                    <option value="10">|——————友情链接列表</option>
                    <option value="11">|——————友情链接添加修改</option>
                    <option value="12">|——————友情链接删除</option>
                    <option value="13">|——————友情链接审核</option>
                    <option value="14">|——————友情链接状态操作</option>
                    <option value="4">管理员管理</option>
                    <option value="5">|———管理员列表</option>
                    <option value="6">|——————管理员添加修改</option>
                    <option value="7">|——————管理员删除</option>
                    <option value="8">|——————管理员状态操作</option>

                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" for="name">
                <span class="x-red">*</span>权限名称
            </label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" id="title" lay-verify="required" name="title"
                       required="" type="text" value="">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" for="name">
                <span class="x-red">*</span>权限控/方
            </label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" id="name" lay-verify="required" name="name"
                       required="" type="text" value="">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input checked="checked" name="status" title="启用" type="radio" value="1">
                <div class="layui-unselect layui-form-radio layui-form-radioed"><i
                        class="layui-anim layui-icon layui-anim-scaleSpring"></i>
                    <div>启用</div>
                </div>
                <input checked="checked" name="status" title="禁用" type="radio" value="0">
                <div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i>
                    <div>禁用</div>
                </div>


            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label" for="desc">
                描述
            </label>
            <div class="layui-input-block">
                <textarea class="layui-textarea" id="condition" name="condition" placeholder="请输入内容"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn" lay-filter="add" lay-submit="">保存</button>
        </div>
    </form>
</div>
<script charset="utf-8" src="lib/layui/layui.js">
</script>
<script charset="utf-8" src="js/x-layui.js">
</script>
<script>
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form()
            , layer = layui.layer;

        //监听提交
        form.on('submit(add)', function (data) {
            var data = data.field;
            $.ajax({
                type: "post",
                url: "xxx",
                data: data,
                dataType: "json",
                success: function (data) {
                    if (data.status == 1) {
                        layer.msg(data.info, {icon: 1, time: 1000});
                        setTimeout(function () {
                            window.parent.location.reload();
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        }, 1000);
                        return false;
                    } else {
                        layer.msg(data.info, {icon: 5, time: 2000});
                        return false;
                    }
                }
            });
            return false;
        });


    });
</script>

</body>

</html>